<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <p>

        </p>
    </div>
    <script>
        function myFun() {
            //倒计时
            //获取现在的毫秒数和指定时间的毫秒数，两者相减
            //剩余的毫秒数
            const date = new Date();
            let num = +new Date('2025-09-05 00:00:00');
            console.log(num - date);
            let sheng = num - date;
            //秒
            let se = parseInt(sheng / 1000 % 60);
            console.log(se);
            let min = parseInt(sheng / 1000 / 60 % 60)
            console.log(min);

            let mon = parseInt(sheng / 1000 / 60 / 60 % 24);
            console.log(mon);
            let day = parseInt(sheng / 1000 / 60 / 60 / 24);
            console.log(day);

            const p = document.querySelector('p');
            p.innerHTML = `剩余：${day}天数：${mon}小时：${min}分钟：${se}秒`
        }


        setInterval(function () {
            myFun();
        }, 1000)
        myFun();
    </script>
</body>

</html>